__autho__ = 'pengfeifu'

'''
子类继承父类调用
'''
class Parent:
    def __init__(self, name, age, sex):
        self.name = name
        self.age = age
        self.sex = sex

    def print_message(self):
        print(self.name, self.sex, self.age)


class Child1(Parent):
    pass


'''
初始化数据，调用父初始化方式
'''


class Child2(Parent):
    def __init__(self, name, age, sex):
        # Parent.__init__(self, name, age, sex) ==== super().__init__(name, age, sex)
        Parent.__init__(self, name, age, sex)


'''
添加自有属性hight
'''


class Child3(Parent):
    def __init__(self, name, age, sex):
        # Parent.__init__(self, name, age, sex) ==== super().__init__(name, age, sex)
        super().__init__(name, age, sex)
        self.height = "170"


class Child4(Parent):
    def __init__(self, name, age, sex, height):
        # Parent.__init__(self, name, age, sex) ==== super().__init__(name, age, sex)
        super().__init__(name, age, sex)
        self.height = height

    def print_message(self):
        print(self.height)


if __name__ == '__main__':
    child_obj1 = Child1(name="张三", age=23, sex="男")
    child_obj1.print_message()

    child_obj2 = Child2(name="李四", age=25, sex="男")
    child_obj2.print_message()

    child_obj3 = Child3(name="李四", age=25, sex="男")
    child_obj3.print_message()
    print(child_obj3.height)

    child_obj4 = Child4(name="李四", age=25, sex="男", height="180")
    child_obj4.print_message()
